docs(ai): git apply on diff#377
Merged
Merged
Conversation
Instead of manually interpreting and applying each hunk via the Edit tool, agents should pipe diffs through git apply or save to a temp file and apply. This avoids slow, error-prone block-by-block editing. https://claude.ai/code/session_013WwSdSkpqSyDZ7WhJWn2f1
When a user provides a diff/patch and asks for it to be applied, agents should use git apply (or patch -p1 as fallback) instead of manually interpreting and applying each hunk via the editor. Added nuance that diffs provided for context/discussion should not be blindly applied. https://claude.ai/code/session_013WwSdSkpqSyDZ7WhJWn2f1
Remove unnecessary bold emphasis and add conditional ("and you need to
update the files") so the instruction doesn't read as "always apply".
https://claude.ai/code/session_013WwSdSkpqSyDZ7WhJWn2f1
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a consistent guideline across the repository’s AI instruction documents to prefer git apply for user-provided diffs (and to treat context-only diffs differently), improving speed and reducing manual patching errors.
Changes:
- Add a new best-practice bullet recommending
git applywhen a user provides an actionable diff. - Clarify that diffs provided only for context/discussion should not be applied.
- Propagate the same instruction across Copilot, Agents, Claude, and the shared template docs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
template/ai-instructions/shared.md |
Adds the new git apply guideline to the shared AI instructions template. |
CLAUDE.md |
Mirrors the new git apply guideline in Claude-specific AI instructions. |
AGENTS.md |
Mirrors the new git apply guideline in agent instructions. |
.github/copilot-instructions.md |
Mirrors the new git apply guideline in Copilot instructions. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Performance Regression Reportscommit: cacc271 There are no regressions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change adds a new instruction to the AI guidance documents to improve efficiency when handling diffs provided by users.
Summary
Added a new best practice guideline across all AI instruction files (Copilot, Agents, Claude, and the shared template) to use
git applywhen applying user-provided diffs rather than manually interpreting each hunk.Key Changes
git applyfor efficiently applying diffs provided by users.github/copilot-instructions.mdAGENTS.mdCLAUDE.mdtemplate/ai-instructions/shared.mdDetails
The new guideline emphasizes that manually interpreting each hunk in a diff is slow and error-prone, and recommends using
git applyas the standard approach. This improves the workflow for AI assistants when users provide diffs as part of their requests.https://claude.ai/code/session_013WwSdSkpqSyDZ7WhJWn2f1